<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/8/14
 * Time: 17:39
 */
namespace App\Http\Controllers\Api\V1_9_1;

use App\Http\Requests\Api\V1_9_1\SupportPassageRequest;
use App\Services\PassageService;
use Illuminate\Http\Request;

class PassageController extends ApiController
{
    protected $passageService;

    public function __construct(PassageService $passageService)
    {
        $this->passageService = $passageService;
    }

    public function getPassageList(Request $request)
    {
        if (empty($request->type)) {
            return $this->responseJson(422);
        }
        return $this->passageService->getPassageList($request->type);
    }

    public function getSupportPassage(SupportPassageRequest $supportPassageRequest)
    {
        return $this->passageService->getSupportPassage($supportPassageRequest->type, $supportPassageRequest->bank_code);
    }

    /**
     * 支持的银行列表
     * @return \Illuminate\Http\JsonResponse
     */
    public function getSupportBankList(Request $request)
    {
        if (empty($request->passage_id)) {
            return $this->responseJson(422);
        }
        return $this->passageService->supportBankList($request->passage_id);
    }


}